
clear 
include "$CODE/pathnames"

* Ensure Stata looks in the local ado folder first
adopath ++ "`c(pwd)'/ado"
* Verify ado path order
adopath

********************************************************************************
**** FIGURE C1: Treatment Allocation, Including Randomization of Direct Questions

use "$DATA/data_list_experiment_final.dta", clear
tab group_1 if sample_part
tab group4_1 if sample_part

********************************************************************************
**** FIGURE C2: Comparison between List Experiment and Direct Question Estimates

cd "$PROJ"
rscript using "$CODE/figure_c2.R"

********************************************************************************
**** FIGURE D1: Total Number of Protesters, Bi-Weekly from December, 2011 through July, 2012

*** Total Number of Protesters

use "$DATA/data_protests_final.dta", clear
preserve
collapse (sum) n_ave, by(year date week)
tsset date
tsfill
collapse (min) date (sum) n_ave, by(year week)
replace week=week-52 if year==2011
replace week=week+3
tsset week
tsfill
replace n_ave=0 if n_ave==.
replace  date=date[_n-1]+7 if date==.
drop if week==.
gen week2=ceil(_n/2)*2
collapse (min) date  (sum)n_ave, by(year week2)
drop if week2>34
replace n_ave=n_ave/1000

#d ;
twoway (scatter n_ave week2, msize(medium)) (lowess n_ave week2, lw(medthick)), graphr(c(white)) 
	ytitle("# of Protesters, ('000)") xtitle("Week # Since the Start of Protests") title("All Cities") 
	legend(off) saving("$TEMP/NPReg All.gph", replace) ylabel(0(100)200) xlabel(0(5)35) ;
#d cr	

*** Trends By City

restore
collapse (min) date (sum) n_ave, by(year week OKATO)
replace week=week-52 if year==2011
replace week=week+3
replace OKATO="" if OKATO=="#N/A"
destring OKATO, gen(okato)
tsset okato week
tsfill, full
replace n_ave=0 if n_ave==.
replace date=date[_n-1]+7 if date==.
drop if week==.
bysort okato: gen week2=ceil(_n/2)*2
collapse (min) date  (sum) n_ave, by( okato week2 )
drop if week2>34
replace n_ave=n_ave/1000

#d ;
twoway (scatter n_ave week2 if okato==45, msize(medium)) (lowess n_ave week2 if okato==45, lw(medthick)), 
	graphr(c(white)) ytitle("# of Protesters, ('000)") xtitle("Week # Since the Start of Protests") 
	title("Moscow") legend(off) ylabel(0(30)90) saving("$TEMP/NPReg Moscow.gph", replace) xlabel(0(5)35);
twoway (scatter n_ave week2 if okato==40, msize(medium)) (lowess n_ave week2 if okato==40, lw(medthick)), 
	graphr(c(white)) ytitle("# of Protesters, ('000)") xtitle("Week # Since the Start of Protests") 
	title("St Petersburg") legend(off) saving("$TEMP/NPReg St Peter.gph", replace) xlabel(0(5)35);
twoway (scatter n_ave week2 if okato==50401, msize(medium)) (lowess n_ave week2 if okato==50401, lw(medthick)), 
	graphr(c(white)) ytitle("# of Protesters, ('000)") xtitle("Week # Since the Start of Protests") 
	title("Novosibirsk") legend(off) saving("$TEMP/NPReg Novosib.gph", replace) xlabel(0(5)35) ;
twoway (scatter n_ave week2 if okato==65401, msize(medium)) (lowess n_ave week2 if okato==65401, lw(medthick)), 
	graphr(c(white)) ytitle("# of Protesters, ('000)") xtitle("Week # Since the Start of Protests") 
	title("Ekaterinburg") legend(off) saving("$TEMP/NPReg Ekater.gph", replace) xlabel(0(5)35);
twoway (scatter n_ave week2 if okato==22401, msize(medium)) (lowess n_ave week2 if okato==22401, lw(medthick)), 
	graphr(c(white)) ytitle("# of Protesters, ('000)") xtitle("Week # Since the Start of Protests") 
	title("Nizhny Novgorod") legend(off) ylabel(0(1)2) saving("$TEMP/NPReg NN.gph", replace) xlabel(0(5)35);
twoway (scatter n_ave week2 if okato==75401, msize(medium)) (lowess n_ave week2 if okato==75401, lw(medthick)), 
	graphr(c(white)) ytitle("# of Protesters, ('000)") xtitle("Week # Since the Start of Protests") 
	title("Kazan") legend(off) ylabel(0(1)2) saving("$TEMP/NPReg Kazan.gph", replace) xlabel(0(5)35);
twoway (scatter n_ave week2 if okato==92401, msize(medium)) (lowess n_ave week2 if okato==92401, lw(medthick)), 
	graphr(c(white)) ytitle("# of Protesters, ('000)") xtitle("Week # Since the Start of Protests") 
	title("Chelyabinsk") legend(off) ylabel(0(1)2) saving("$TEMP/NPReg Chelyab.gph", replace) xlabel(0(5)35);
twoway (scatter n_ave week2 if okato==52401, msize(medium)) (lowess n_ave week2 if okato==52401, lw(medthick)), 
	graphr(c(white)) ytitle("# of Protesters, ('000)") xtitle("Week # Since the Start of Protests") 
	title("Omsk") legend(off) ylabel(0(1)2) saving("$TEMP/NPReg Omsk.gph", replace) xlabel(0(5)35);
#d cr

#d ;

graph combine "$TEMP/NPReg All.gph" "$TEMP/NPReg Moscow.gph" "$TEMP/NPReg St Peter.gph" "$TEMP/NPReg Novosib.gph" "$TEMP/NPReg Ekater.gph"
	"$TEMP/NPReg NN.gph" "$TEMP/NPReg Kazan.gph" "$TEMP/NPReg Chelyab.gph" "$TEMP/NPReg Omsk.gph", graphr(c(white)) xcommon ;
#d cr
graph export "$REPLICATION/Figures_Appendix/figure_D1.pdf", as(pdf) replace

********************************************************************************
**** FIGURE D2: Conditional Marginal Effects of Week Number on Protest Participation

use "$DATA/data_crosscity_analysis_final.dta", clear

areg logprot c.week_year_n##c.week_year_n , a(OKATO) 
margins , dydx(week_year_n) at(week_year_n = (1(1)42))
marginsplot , yline(0) xtitle("Week number") xlabel(1 5(5)40) title("")

graph export "$REPLICATION/Figures_Appendix/figure_D2.pdf", as(pdf) replace

